Description:
DIC detects invalid type casts that will result in a
System.InvalidCastException
being thrown at runtime. Such situations occur when a variable is checked to
be an instance of type A and then inside the same conditional
branch is casted to another type B which is not the same type
as A and is not a base type of A.
Incorrect:
var obj:TObject;
...
if obj is String then
if (obj as StringBuilder).Chars[0] = '#' then
...
Correct:
var obj:TObject ;
...
if obj is String then
if (obj as String).Chars[0] = '#' then
...